package ca.uguu.gamelib.libgdx.concepts;

import java.util.AbstractMap;

import ca.uguu.gamelib.libgdx.globals.Constants;

public class OrientedSpriteArea extends SpriteArea{
	public enum Orientation{
		UP, DOWN, LEFT, RIGHT;
	}
	final public Orientation orientation;
	
	public OrientedSpriteArea(int centreX, int centreY, int width, int height, Orientation orientation){
		super(centreX, centreY, width, height);
		this.orientation = orientation;
	}
	public OrientedSpriteArea(AbstractMap<String, Object> area){
		super(area);
		String orientation = (String)area.get("orientation");
		if(orientation == null){
			this.orientation = null;
		}else if(orientation.equals("left")){
			this.orientation = Orientation.LEFT;
		}else if(orientation.equals("right")){
			this.orientation = Orientation.RIGHT;
		}else if(orientation.equals("up")){
			this.orientation = Orientation.UP;
		}else if(orientation.equals("down")){
			this.orientation = Orientation.DOWN;
		}else{ //Dunno, lawl
			this.orientation = null;
		}
	}
	
	@Override
	public float getAngle(){
		switch(this.orientation){
			case UP:{
				return 0;
			}
			case DOWN:{
				return (float)Math.PI;
			}
			case LEFT:{
				return (float)Math.PI + Constants.HALF_PI;
			}
			case RIGHT:{
				return Constants.HALF_PI;
			}
			default:{ //Proper usage would be to check the orientation before calling this method to make sure it's not null.
				return 0;
			}
		}
	}
}
